package com.lanju.controller;

import java.util.Date;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import com.lanju.entity.Seekadvice;
import com.lanju.entity.User;
import com.lanju.service.JedisService;
import com.lanju.service.SeeAdviceService;
import com.lanju.util.ServletUtil;

@Controller
@RequestMapping("/seeadvice")
public class SeeAdviceController {
	
	private static final Logger LOGGER = LoggerFactory.getLogger(SeeAdviceController.class);
	
	@Autowired
	SeeAdviceService seeAdviceService;
	 @Resource
	JedisService jedisService;
	
	@RequestMapping("/addSeeAdvice")
	@ResponseBody
	Map<String,Object> addSeeAdvice(HttpServletRequest request,HttpSession session){
		Map<String, Object> param = ServletUtil.getParameterMap(request);
		JSONObject json = JSONObject.parseObject(JSONObject.toJSONString(param));
		Seekadvice sa = json.toJavaObject(Seekadvice.class);
		User user =(User) session.getAttribute("userModel");
		sa.setCreator(user.getUserId());
		sa.setCreate_time(new Date());
		return seeAdviceService.addSeeAdvice(sa);
		
	}
	

}
